if (!dojo._hasResource["dojoide.core._utils"]) {
    dojo._hasResource["dojoide.core._utils"] = true;
    dojo.provide("dojoide.core._utils");

	
	//startsWith: checking if the current string starts with str
	String.prototype.startsWith = function(str){
	    return (this.substring(0, ('' + str).length) == '' + str);
	};
	
	//replaceAll: replacing all str occurancies with newStr
	String.prototype.replaceAll = function(str, newStr){
		var changedStr = '' + this;
		while(changedStr.indexOf(str) > -1){
			changedStr = changedStr.replace(str, newStr);
		}
	    return changedStr;
	};

	//findOccurances: find all occurances of str within startOffset and endOffset
	//range and return them in array
	String.prototype.findOccurances = function(str, startOffset, endOffset){
		var occurances = [];
		var occurance = -1;
		do{
			occurance = this.indexOf(str, occurance + 1);
			if(startOffset && occurance < startOffset){
				continue;
			}
			if(endOffset && occurance > endOffset){
				break;
			}
			if (occurance > -1) {
				occurances.push(occurance);
			}
		}while(occurance > -1);
	    return occurances;
	};
	
	//indexOfNonWordChar: find index of the first non-word character
	String.prototype.indexOfNonWordChar = function(){
    	var nonWordRE = /[^A-Za-z0-9_.]/;
    	var nonWordREResult = nonWordRE.exec(this);
        return nonWordREResult?nonWordREResult.index:-1;
	};
	
	//lastIndexOfNonWordChar: find index of the last non-word character
	String.prototype.lastIndexOfNonWordChar = function(){
    	var nonWordRE = /[^A-Za-z0-9_.]/g;
    	var nonWordREResult = nonWordRE.exec(this);
    	var temp = nonWordREResult;
        while(temp){
			temp = nonWordRE.exec(this);
			if(temp){
				nonWordREResult = temp;
			}
        }
        return nonWordREResult?nonWordREResult.index:-1;
	};
	
    //remove html code from str
    dojoide.core.removeHtml = function(str){
    	//replace breaks with new lines
        var findBreaks = new RegExp("<br(?: |).*?>", "g");
        str = str.replace(findBreaks, "\n");

    	//remove html tags
        var findHtmlTags = new RegExp("<.*?>", "g");
        str = str.replace(findHtmlTags, "");
        
        return str;
    };

    //remove html code from str
    dojoide.core.unescapeXml = function(str){
    	//remove escape sequences for special characters in XML: &<>"' 
		str = str.replace(/&nbsp;/gm, " ").replace(/&amp;/gm, "&").replace(/&lt;/gm, "<").replace(/&gt;/gm, ">").replace(/&quot;/gm, "\"").replace(/&#39;/gm, "\'");
        return str;
    };

    //colorize object child nodes
    dojoide.core.colorizeChildNodes = function(obj){
        if (obj.style) {
            obj.style.border = '1px solid blue';
        }
        if (!obj.childNodes) {
            return;
        }
        for (node in obj.childNodes) {
            try {
                node.style.border = '1px solid blue';
            } catch (err) {
            }
        }
    };
    
}
